package com.ssy.lingxi.platform.manage.entity.content;

import com.ssy.lingxi.platform.manage.handler.convert.JpaJsonToLongListConverter;
import lombok.Data;

import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 资讯实体类
 * @author fhj
 * @version 2.0.0
 * @date 2020/9/21
 */
@Data
@Entity
@Table(schema = "public", name = "man_member_information",
        indexes = {@Index(name = "man_member_information_member_id_member_role_id_idx", columnList = "memberId,memberRoleId")})
public class MemberInformation implements Serializable {
    private static final long serialVersionUID = -1164944975240542666L;
    /**
     * 主键id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "member_information_seq")
    @SequenceGenerator(sequenceName = "man_member_information_seq", name = "member_information_seq", allocationSize = 1)
    private Long id;

    /**
     * 会员id
     */
    @Column(columnDefinition = "int8")
    private Long memberId;

    /**
     * 会员角色id
     */
    @Column(columnDefinition = "int8")
    private Long memberRoleId;

    /**
     * 标题
     */
    @Column(columnDefinition = "varchar(60)")
    private String title;

    /**
     * 栏目ID
     */
    private Long columnId;

    /**
     * 推荐标签 1-头条文章 2-轮播新闻 3-图片新闻 4-推荐阅读 5-行情推荐 6-本栏推荐
     */
    private Integer recommendLabel;

    /**
     * 排序
     */
    private Integer sort;

    /**
     * 浏览数
     */
    private Integer readCount;

    /**
     * 一级分类ID
     */
    private Long firstCategoryId;

    /**
     * 二级分类ID
     */
    private Long secondCategoryId;

    /**
     * 三级分类ID
     */
    private Long thirdlyCategoryId;

    /**
     * 一级分类名称
     */
    private String firstCategoryName;

    /**
     * 二级分类名称
     */
    private String secondCategoryName;

    /**
     * 三级分类名称
     */
    private String thirdlyCategoryName;

    /**
     * 标签ID集合
     */
    @Convert(converter = JpaJsonToLongListConverter.class)
    @Column(columnDefinition = "jsonb")
    private List<Long> labelIds = new ArrayList<>();

    /**
     * 图片地址
     */
    private String imageUrl;

    /**
     * 摘要
     */
    @Column(columnDefinition = "varchar(300)")
    private String digest;

    /**
     * 内容
     */
    @Column(columnDefinition = "text")
    private String content;

    /**
     * 状态 1-待上架 2-已上架 3-已下架
     */
    private Integer status = 1;

    /**
     * 收藏数
     */
    private Integer collectCount = 0;

    /**
     * 创建时间
     */
    private Long createTime = System.currentTimeMillis();
}
